<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:cc="http://java.sun.com/jsf/composite"
	xmlns:ic="http://ivyteam.ch/jsf/component"
	xmlns:p="http://primefaces.org/ui"
	xmlns:pe="http://primefaces.org/ui/extensions"
	xmlns:pm="http://primefaces.org/mobile"
    xmlns:c="http://java.sun.com/jsp/jstl/core">

<cc:interface componentType="IvyComponent">
	<cc:attribute name="status" />
	<cc:attribute name="tasks" />
	<cc:attribute name="callback"/>
</cc:interface>

<cc:implementation>
	<ui:repeat var="task" value="#{cc.attrs.tasks}">
		<p:panel styleClass="task" rendered="#{cc.attrs.status == task.status}">
			<f:facet name="header">
				<div style="cursor: pointer;" class="sticker-header" ondblclick="showEditView_#{task.id}()">
					<h:form>
						<p:outputPanel layout="block">
							<h:outputText styleClass="outputField taskId" value="Task ##{task.id}" />
							<p:remoteCommand name="showEditView_#{task.id}"
								actionListener="#{cc.attrs.callback.onDbClickOnViewDialog(task)}"
								update=":#{p:component('editViewDialog')}"
								oncomplete="handleComplete(xhr, status, args)">
							</p:remoteCommand>
						</p:outputPanel>
					</h:form>
				</div>
			</f:facet>
			<h:panelGroup styleClass="taskInfo">
				<h:outputText styleClass="outputField taskTitle" value="#{task.title}" />
				<h:outputText styleClass="outputField taskDescription" value="#{task.description}" style="max-height:150px; overflow-y: auto;"/>
			</h:panelGroup>
			
			<f:facet name="footer">
				<p:commandButton rendered="#{cc.attrs.status == 1}" value="Take" />

				<p:commandButton rendered="#{cc.attrs.status == 2}" value="Log Work" />
				<p:commandButton rendered="#{cc.attrs.status == 2}" value="Resolve" />

				<p:commandButton rendered="#{cc.attrs.status == 3}" value="Reject" />
				<p:commandButton rendered="#{cc.attrs.status == 3}" value="Accept" />

				<p:commandButton rendered="#{cc.attrs.status == 4}" value="Archive" />
			
			</f:facet>
			
			
		</p:panel>
	</ui:repeat>
</cc:implementation>

</html>
